package com.ojoin.trade.common.web.service.impl;

import java.math.BigInteger;
import java.security.interfaces.RSAPublicKey;

import org.apache.commons.codec.binary.Hex;
import org.springframework.stereotype.Component;

import com.ojoin.trade.common.utils.RSAUtils;
import com.ojoin.trade.common.web.service.IRSAService;

@Component
public class RSAService implements IRSAService{

	@Override
	public RSAPublicKey getDefaultPublicKey() {
		return RSAUtils.getDefaultPublicKey();
	}
	
	@Override
	public String encryptString(String plaintext) {
		return RSAUtils.encryptString(plaintext);
	}

	@Override
	public String decryptString(String encrypttext) {
		return RSAUtils.decryptString(encrypttext);
	 }
	@Override
	public String decryptStringByJs(String encrypttext) {
		return RSAUtils.decryptStringByJs(encrypttext);
	}

	@Override
	public String encodeHex(BigInteger key) {
		return new String(Hex.encodeHex(key.toByteArray()));
	}

}